package cn.azzhu.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author azzhu
 * @create 2020-08-18 11:19:20
 */
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(value = ArithmeticException.class)
    public ModelAndView error(Exception e) {
        System.out.println("******Exception msg is:  "+e.getMessage());
        ModelAndView mv = new ModelAndView();
        mv.addObject("myexception", e);
        mv.setViewName("error");
        return mv;
    }
}
